import Mock from 'mockjs'

const Random = Mock.Random // Mock.Random 是一个工具类，用于生成各种随机数据

let payInList = []

for (let i = 0; i < 50; i++) { // 可自定义生成的个数
	let template = {
		"id": Random.guid(),
		"amount": Random.float(1200, 4800, 2, 2),
		"name": Random.cname(),
		"startTime": Random.date(),
		"endTime": Random.date(),
		"payInTitle": Random.date('yyyy') + "学年" + Random.cword('春秋') + "季学费（大" + Random.cword('一二三四') + "）"
	}
	payInList.push(template)
}

export default [
	{
		url: '/data/payInList',
		type: 'get',
		response: config => {
			const page = 1, limit = 20
			let mockList = payInList
			const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
			return {
				code: 0,
				data: {
					total: mockList.length,
					list: pageList
				}
			}
		}
	},
	{
		url: '/data/payInDetail',
		type: 'get',
		response: config => {
			const { id } = config.body
			for (const detail of payInList) {
				if (detail.id === id) {
					return {
						code: 0,
						data: detail
					}
				}
			}
		}
	},

]